package edu.mit.csail.relo.intro.preferences;

import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;

import edu.mit.csail.relo.intro.ReloIntroPlugin;

/**
 * @author vineet
 *
 */
public class PreferenceConstants extends AbstractPreferenceInitializer {

    public static final String Java5CheckKey = "Relo.Java5Check5";
    public static final String Java5CheckPrompt = "Check VM Version for Java 5 at Startup";

    public static final String BuilderCheckConnectionAtStartupKey = "Relo.ConnectionChecked";
    public static final String BuilderCheckConnectionAtStartupPrompt = "Check Builder Connections at Startup";

    public static final String LabelItemsWithContextKey = "Relo.LabelItemsWithContext";
    public static final String LabelItemsWithContextPrompt = "Show Context On Labels";

    public static final String DisableIncreamentBuildKey = "Relo.DisableIncreamentBuild";
    public static final String DisableIncreamentBuildPrompt = "Disable Increament Build";

    public static boolean labelItemsWithContext = false;
    
    public static boolean showMethodReturnTypes = false;

    public static boolean disableIncreamentBuild = false;

    /*
     * (non-Javadoc)
     * 
     * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
     */
    public void initializeDefaultPreferences() {
        IPreferenceStore prefStore = ReloIntroPlugin.getDefault().getPreferenceStore();

        prefStore.setDefault(PreferenceConstants.Java5CheckKey, true);
        prefStore.setDefault(PreferenceConstants.BuilderCheckConnectionAtStartupKey, true);
        prefStore.setDefault(PreferenceConstants.LabelItemsWithContextKey, false);
        prefStore.setDefault(PreferenceConstants.DisableIncreamentBuildKey, false);
    }
    
    private static boolean prefsLoaded = false;

    public static void loadPrefs() {
    	if (prefsLoaded) return;
    	prefsLoaded = true;
    	
    	reloadPrefs();
    }
    	
    public static void reloadPrefs() {
        IPreferenceStore prefStore = ReloIntroPlugin.getDefault().getPreferenceStore();
    	labelItemsWithContext = prefStore.getBoolean(PreferenceConstants.LabelItemsWithContextKey);
    	
    	disableIncreamentBuild = prefStore.getBoolean(PreferenceConstants.DisableIncreamentBuildKey);
    	
    	showMethodReturnTypes = Boolean.valueOf(
    								org.eclipse.jdt.ui.PreferenceConstants.getPreference(
    										org.eclipse.jdt.ui.PreferenceConstants.APPEARANCE_METHOD_RETURNTYPE, 
    										null))
    									.booleanValue();
    }
    
}
